package org.ami.onlineschool.ui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import java.awt.FlowLayout;
import javax.swing.JButton;
import java.awt.BorderLayout;
import java.io.File;

import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class OnlineSchoolDashboard {

	private JFrame frmOnlineSchool;
	private JTextField txtSchoolDataLocation;

	/**
	 * Launch the application.
	 * @throws UnsupportedLookAndFeelException 
	 * @throws IllegalAccessException 
	 * @throws InstantiationException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
		
		UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

		
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					OnlineSchoolDashboard window = new OnlineSchoolDashboard();
					window.frmOnlineSchool.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public OnlineSchoolDashboard() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmOnlineSchool = new JFrame();
		frmOnlineSchool.setTitle("Online School");
		frmOnlineSchool.setBounds(100, 100, 676, 194);
		frmOnlineSchool.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frmOnlineSchool.getContentPane().setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		frmOnlineSchool.getContentPane().add(panel, BorderLayout.CENTER);
		
		JButton btnCourseManagement = new JButton("Course Management...");
		btnCourseManagement.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				UIDefineCourses.launchWindow(txtSchoolDataLocation.getText());
			}
		});
		panel.add(btnCourseManagement);
		
		JButton btnStudentManagement = new JButton("Student Management...");
		btnStudentManagement.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				UIDefineStudents.launchWindow(txtSchoolDataLocation.getText());
			}
		});
		panel.add(btnStudentManagement);
		
		JButton btnManageEnrolment = new JButton("Manage Enrolment...");
		btnManageEnrolment.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				UIDefineEnrolment.launchWindow(txtSchoolDataLocation.getText());
			}
		});
		panel.add(btnManageEnrolment);
		
		JButton btnCourseExecution = new JButton("Course Execution...");
		btnCourseExecution.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				UIMonitorCourseExecution.launchWindow(txtSchoolDataLocation.getText());
			}
		});
		panel.add(btnCourseExecution);
		
		JPanel panel_1 = new JPanel();
		frmOnlineSchool.getContentPane().add(panel_1, BorderLayout.NORTH);
		panel_1.setLayout(new BorderLayout(0, 0));
		
		txtSchoolDataLocation = new JTextField();
		txtSchoolDataLocation.setText(new File("").getAbsolutePath());
		panel_1.add(txtSchoolDataLocation);
		txtSchoolDataLocation.setColumns(10);
		
		JButton btnBrowse = new JButton("Browse...");
		panel_1.add(btnBrowse, BorderLayout.EAST);
	}

}
